package controller

import (
	"speechsoundsalarm/util"
	"strconv"
)

func Display(d util.Data) (result string) {
	// <tr><td>{{.number}}</td> <td>{{.alarmTime}} </td> <td>{{.alarmText}} </td></tr>
	//  <button type="submit" class="btn btn-default">注	册</button>

	for index, v := range d.Info {
		closeBut := "<div class=\"inline\"><form class=\"form col-md-6\" role=\"form\" method=\"post\" name=\"input\" action=\"/delete\"> <button type=\"submit\" class=\"glyphicon glyphicon-remove\" name=\"table\" ></button><input type=\"text\" class=\"form-control hidden\"  name=\"id\" value=\"" + strconv.Itoa(index) + "\" /></form>"
		reSetBut := "<form class=\"form col-md-6\" role=\"form \" method=\"post\" name=\"reset\" action=\"/reset\"> <button type=\"submit\" class=\"glyphicon glyphicon-refresh\" name=\"rsetbt\" ></button><input type=\"text\" class=\"form-control hidden\"  name=\"id\" value=\"" + strconv.Itoa(index) + "\" /></form></div>"
		if v.AlarmType == "timing" {
			reSetBut = "</div>"
		}
		result += "<tr> <td>" + strconv.Itoa(index+1) + "</td> <td>" + v.Date + "</td> <td>" + v.Text + "</td><td>" + v.AlarmType + "</td><td>" + strconv.Itoa(v.Count) + "</td><td>" + strconv.Itoa(v.Space) + "</td><td>" + closeBut + reSetBut + "</td></tr>"
	}
	return result
}
